package power.game.sixtysix.entity;


public class Card {

	private Integer id;
	private CardValue value;
	private CardColor color;
	
	public Card(Integer id) {
		this.id = id;
		int v = id % 5;
		switch(v) {
		case 0:
			value = CardValue.Also;
			break;
		case 1:
			value = CardValue.Felso;
			break;
		case 2:
			value = CardValue.Kiraly;
			break;
		case 3:
			value = CardValue.Tiz;
			break;
		case 4:
			value = CardValue.Asz;
			break;
		}
		int c = id / 5;
		switch(c) {
		case 0:
			color = CardColor.Tok;
			break;
		case 1:
			color = CardColor.Makk;
			break;
		case 2:
			color = CardColor.Level;
			break;
		case 3:
			color = CardColor.Sziv;
			break;
		}
	}
	
	public String toString() {
		return color + "-" + value;
	}

	public CardValue getCardValue() {
		return value;
	}

	public CardColor getCardColor() {
		return color;
	}

	public boolean compare(Card card, CardColor talon) {
		if (this.color.equals(card.color)) {
			return this.getCardValue().getValue() > card.getCardValue().getValue();
		} else if (card.color.equals(talon)) {
			return false;
		} else {
			return true;
		}
	}
	
	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((id == null) ? 0 : id.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		Card other = (Card) obj;
		if (id == null) {
			if (other.id != null)
				return false;
		} else if (!id.equals(other.id))
			return false;
		return true;
	}
	
	
}
